<%layout("/common/_layout.html"){ %>
  <%#ajax userTable:{%>
  <div class="am-cf am-padding">
    <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">业务管理</strong> / <small>通知管理</small></div>
  </div>
  <div class="am-g">
    <div class="am-u-sm-12">
      <form class="am-form" id="list-form" action="${base}/notice/list" method="post">
        <input type="hidden" id="keywords" name="keywords" value='${keywords!""}' />
        <table class="am-table am-table-bordered am-table-radius table-main" style="padding:0;">
          <tbody>
            <tr>
              <th class="am-text-middle">所属企业</th>
              <td>
                <div class="am-u-sm-10">
                  <select data-am-selected="{btnSize:'sm'}" id="orgID" name="orgID">
                            <option value="37714">大掌柜</option>
                        </select>
                </div>
              </td>
              <th class="am-text-middle">发布时间</th>
              <td>
              <div class="am-u-sm-10">
                <div class="am-form am-form-inline">
                  <div class="am-form-group am-form-icon">
                    <i class="am-icon-calendar"></i>
                    <input type="text" class="am-form-field am-input-sm" id="startTime" value="${startTime!}" placeholder="开始日期" data-am-datepicker>
                  </div>
                  <div class="am-form-group">至</div>
                  <div class="am-form-group am-form-icon">
                    <i class="am-icon-calendar"></i>
                    <input type="text" class="am-form-field am-input-sm" id="endTime" value="${endTime!}" placeholder="结束日期" data-am-datepicker>
                  </div>
                </div>
              </div>
            </td>
            </tr>
            <tr>
            <th class="am-text-middle">类型</th>
              <td>
                <div class="am-u-sm-10">
                  <select data-am-selected="{btnSize:'sm'}" id="type" name="type">
                            <option value="0" <%if(type! == "0") {%>selected<%}%>>新闻资讯</option>
                            <!-- <option value="1" <%if(type! == "1") {%>selected<%}%>>广播消息</option>
                            <option value="2" <%if(type! == "2") {%>selected<%}%>>消息管理</option> -->
                        </select>
                </div>
              </td>
              <th class="am-text-middle">是否发布</th>
              <td>
                <div class="am-u-sm-10">
                  <select data-am-selected="{btnSize:'sm'}" id="enabled" name="enabled" >
                            <option value="-1" <%if(enabled! == "-1") {%>selected<%}%>>所有</option>
                            <option value="1" <%if(enabled! == "1") {%>selected<%}%>>是</option>
                            <option value="0" <%if(enabled! == "0") {%>selected<%}%>>否</option>
                        </select>
                </div>
              </td>
            </tr>
            <tr>
              <th class="am-text-middle">名称</th>
              <td>
                <div class="am-u-sm-10">
                  <input type="text" id="title" class="am-form-field am-input-sm" value="${title!}" />
                </div>
              </td>
              <th colspan="2"></th>
            </tr>
            <tr>
                <td colspan="4">
                  <div align='right'>
                    <button type="button" class="am-btn am-btn-default am-btn-sm am-text-secondary" id="submit-btn">搜索</button>
                  </div>
                </td>
            </tr>
          </tbody>
        </table>
      </form>
    </div>
    <div class="am-u-sm-12 am-u-md-12" style="padding:0 1.6rem 1.6rem 1rem;margin:0;">
      <div class="am-btn-toolbar" style="padding-left:.5rem;">
        <div class="am-btn-group am-btn-group-xs">
        <%if(so.hasPermission("NOTICE_ADD")) {%>
          <button type="button" class="am-btn am-btn-default" onclick="location.href='${base}/notice/add'"><span class="am-icon-plus"></span> 新增</button>
          <%}%>
          <%if(so.hasPermission("NOTICE_DELETE")) {%>
          <button type="button" id="deleteButton" disabled="disabled" class="am-btn am-btn-default"  onclick="deleteAll('${base}/notice/delete')"><span class="am-icon-trash-o"></span> 删除</button>
          <%}%>
        </div>
      </div>
    </div>
  </div>
  <div class="am-g">
    <div class="am-u-sm-12">
    <div class="am-scrollable-horizontal">
      <table class="am-table am-table-striped am-table-hover table-main">
        <thead>
          <tr class="am-text-nowrap">
            <th class="table-check"><input type="checkbox"  id="allCheck"/></th>
            <th class="table-title">新闻资讯/广播消息标题</th>
            <th class="table-title">简短描述</th>
            <th class="table-title">创建者</th>
            <th class="table-date">发布时间/创建时间</th>
            <th class="table-date">修改时间</th>
            <th class="table-title">排序</th>
            <th class="table-title">是否发布</th>
            <th class="table-title">预览</th>
            <th class="table-set">操作</th>
          </tr>
        </thead>
        <tbody>
          <%for(list in pager.list!){%>
            <tr>
              <td><input type="checkbox" name="ids" value="${list.id}"></td>
              <td>${list.title}</td>
              <td>${list.short_desc}</td>
              <td>${list.creator}</td>
              <td>${list.created_time, dateFormat="yyyy-MM-dd HH:mm:ss"}</td>
              <td>${list.last_updated_time, dateFormat="yyyy-MM-dd HH:mm:ss"}</td>
              <td>${list.sort}</td>
              <td>
                <%if(list.enabled == 1){%>
                                    已发布
                <%}else{%>
                                    未发布
                <%}%>
              </td>
              <td>
                <div class="am-btn-toolbar">
                  <div class="am-btn-group am-btn-group-xs">
                    <a href="${base}/..${list.h5_url}" target="_blank"><span class="am-icon-share-square-o">预览</span></a>     
                  </div>
                </div>
              </td>
              <td>
                <div class="am-btn-toolbar">
                  <div class="am-btn-group am-btn-group-xs">     
                    <%if(so.hasPermission("NOTICE_EDIT")) {%>      
                    <button type="button" class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="location.href='${base}/notice/edit?id=${list.id}'"><span class="am-icon-pencil-square-o"></span>修改</button>
                    <%}%>
                  </div>
                </div>
              </td>         
            </tr>
           <%}%> 
        </tbody>
     </table>
     </div>
      <div class="am-cf">
         <!-- 分页 -->
         <%if (pager.list.~size > 0){%>
             <div class="am-fr">
                 <% include("/admin/common_pager.tpl"){}%>
             </div>
         <%}else{%>
             <div class="am-kai">
               <h3>没有找到任何记录!</h3>
             </div>
         <%}%>
      </div>
    
    </div>
  </div>
  <script type="text/javascript">
    $(function(){
      var keywordsObj = {};
      $("#submit-btn").on("click",function(){
        if($("#orgID").val())
          keywordsObj.orgID = $("#orgID").val();
        if($("#type").val())
          keywordsObj.type = $("#type").val();
        if($("#enabled").val())
          keywordsObj.enabled = $("#enabled").val();
        if($("#startTime").val())
          keywordsObj.startTime = $("#startTime").val();
        if($("#endTime").val())
          keywordsObj.endTime = $("#endTime").val();
        if($("#title").val())
          keywordsObj.title = $("#title").val();

        var keywords = "";
        if(!$.isEmptyObject(keywordsObj)){
          keywords = JSON.stringify(keywordsObj);
        }
        console.log("keywords = "+ keywords);

        $("#keywords").val(keywords);
        $("#list-form").submit();
      });
    });
  </script>
  <%}%>
<%}%>